# 卦象身份证，压缩卦象的信息。
from mapping.GuaCombination import GuaCombination

data_examples = [
    (5,3,3,42, 15, '5335217', 1946463),
    (4,3,9,58, 58, '43972XX', 2714673)
]


def min_max_index():
    # 计算最小索引
    idx_min = GuaCombination.get_index4(0, 0, 0, 0)
    print("最小索引:", idx_min)  # 输出: 0

    # 计算最大索引
    idx_max = GuaCombination.get_index4( 11, 59,63, 63)
    print("最大索引:", idx_max)  # 输出: 2949119
def gua_combination(m=4,  d=3, dg=9, gua=58, biangua=58,gc_str='43972XX', gc_idx=2714673):
    gc = GuaCombination(m, d,dg, gua, biangua)
    print(gc)  # {'m': 5, 'dg': 3, 'd': 3, 'gua': 42, 'biangua': 15, 'str': '5335217', 'idx': 1946463}
    print(gc.to_list)  # [5, 3, 3, 42, 15, '5335217', 1946463]
    print('gc_str:',gc.to_str)  # 5335217
    print('gc_idx:',gc.to_idx)  # 1946463,最常用
    print('from_gua_str:',GuaCombination.from_gua_str(gc_str))  # 同 print(gc)
    print('from_gc_idx（返回4位）:',GuaCombination.from_index4(gc_idx))  # (5, 3, 42, 15)
    print('from_gc_idx（返回5位）:',GuaCombination.from_index5(gc_idx))  # (5, 3, 3, 42, 15)
if __name__ == '__main__':
    for example in data_examples:
        print('*'*40,example[-2],'*'*40)
        gua_combination(*example)



